home *** CD-ROM | disk | FTP | other *** search
/ Deutsche Edition 1 / Deutsche Edition 1.iso / amok / 081-090 / amok87 / stopwatch / devicesupport37.mod next >
Text File  |  1993-11-04  |  2KB  |  72 lines

  1. (*---------------------------------------------------------------------------
  2.  :Program.     DeviceSupport37.mod
  3.  :Contents.    Easy Device access (OS 2.04+ Version)
  4.  :Author.      Christian Stiens
  5.  :Address.     Snail-Mail:           E-Mail:
  6.  :Address.     Heustiege 2           UUCP: Christian_Stiens@ouzonix.bo.open.de
  7.  :Address.     W-4710 Lüdinghausen   FIDO: 2:245/5802.25
  8.  :Copyright.   public domain
  9.  :Language.    Oberon
  10.  :Translator.  Amiga Oberon 3.01
  11.  :History.     V1.0, 18-Feb-93
  12. ---------------------------------------------------------------------------*)
  13.  
  14. MODULE DeviceSupport37;
  15.  
  16.   IMPORT
  17.     e := Exec, SYSTEM;
  18.  
  19.   TYPE
  20.     InitProc* = PROCEDURE(ioReq: e.MessagePtr);
  21.  
  22.   VAR
  23.     ioErr* : INTEGER;
  24.  
  25.  
  26.   PROCEDURE OpenDev* (name   : ARRAY OF CHAR;
  27.                       unit   : LONGINT;
  28.                       flags  : LONGSET;
  29.                       ioSize : INTEGER;
  30.                       ioInit : InitProc): e.MessagePtr; (* $CopyArrays- *)
  31.     VAR
  32.       port: e.MsgPortPtr;
  33.       ioReq: e.IORequestPtr;
  34.  
  35.   BEGIN
  36.     port := e.CreateMsgPort();
  37.     IF port = NIL THEN RETURN NIL END;
  38.     IF ioSize = 0 THEN ioSize := SIZE(e.IOStdReq) END;
  39.     ioReq := e.CreateIORequest(port,ioSize);
  40.     IF ioReq = NIL THEN e.DeleteMsgPort(port); RETURN NIL END;
  41.     IF ioInit # NIL THEN ioInit(ioReq) END;
  42.     IF e.OpenDevice(name,unit,ioReq,flags) # 0 THEN
  43.       e.DeleteIORequest(ioReq);
  44.       e.DeleteMsgPort(port);
  45.       RETURN NIL
  46.     END;
  47.     RETURN ioReq;
  48.   END OpenDev;
  49.  
  50.  
  51.   PROCEDURE CloseDev* (VAR ioReq: e.APTR);
  52.     VAR port: e.MsgPortPtr;
  53.   BEGIN
  54.     IF ioReq#NIL THEN
  55.       port := SYSTEM.VAL(e.MessagePtr,ioReq).replyPort;
  56.       e.CloseDevice(ioReq);
  57.       e.DeleteIORequest(ioReq);
  58.       e.DeleteMsgPort(port);
  59.       ioReq := NIL;
  60.     END;
  61.   END CloseDev;
  62.  
  63.  
  64.   PROCEDURE DoCommand* (ioReq: e.MessagePtr; cmd: INTEGER);
  65.   BEGIN
  66.     ioReq(e.IORequest).command := cmd;
  67.     ioErr := e.DoIO(ioReq);
  68.   END DoCommand;
  69.  
  70. END DeviceSupport37.
  71.  
  72.